<?php
class DtupModel extends Action{
	
	//公版
	public function getnopw($typeid,$alipayno,$qqno){
		$info=collectinfo(__METHOD__,'$typeid,$alipayno,$qqno',array($typeid,$alipayno,$qqno));
		
		
		$dtup=M('dtup');
		$dtupo=$dtup->where("f_dtup_typeid=".$typeid." AND dtupalipayno='".$alipayno."'")->find();
		//如果有，说明这个alipay已经交易完成了，不得再用
		if($dtupo){
			$rslt=3;
		}else{
			$dtupo=$dtup->join('tb_type ON f_dtup_typeid=typeid')->where("f_dtup_typeid=".$typeid." AND dtupstat=0")->order('dtupid ASC')->find();
			if($dtupo){
				$rslt=1;
				$data['dtupo']=$dtupo;
				$tm=date('Y-m-d H:i:s',time());
				$dt=array('dtupalipayno'=>$alipayno,'dtupusrqqno'=>$qqno,'dtuptiqutm'=>$tm,'dtupstat'=>1);
				$dtup->where('dtupid='.$dtupo['dtupid'])->setField($dt);
			}else{
				$rslt=0;
			}
		}
		
		$data['rslt']=$rslt;

		
		return createarrok('ok',$data,'',$info);
	}

		//公版
	public function getnopwbyalipaynoandqqno($alipayno,$qqno){
		$info=collectinfo(__METHOD__,'$alipayno,$qqno',array($alipayno,$qqno));
		
		
		$dtup=M('dtup');
		$dtupo=$dtup->join('tb_type ON f_dtup_typeid=typeid')->where("dtupalipayno='".$alipayno."' AND dtupusrqqno='".$qqno."'")->find();
		//如果有，说明这个alipay已经交易完成了，不得再用
		if($dtupo){
			$rslt=1;
			$data['dtupo']=$dtupo;
		}else{
			$rslt=0;
		}
		
		$data['rslt']=$rslt;

		
		return createarrok('ok',$data,'',$info);
	}

	public function getmobyalipayno($alipayno){
		$info=collectinfo(__METHOD__,'$alipayno',array($alipayno));
		
		
		$dtup=M('dtup');
		$dtupo=$dtup->where("dtupalipayno='".$alipayno."'")->find();
		
		
		return createarrok('ok',$dtupo,'',$info);
	}

}

?>